{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# WuxingRelations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><div></div><div></div><div><strong>Installed Packages</strong><ul><li><span>YiJingFramework.EntityRelations, 4.0.1</span></li></ul></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#r \"nuget:YiJingFramework.EntityRelations\"\n",
    "using YiJingFramework.EntityRelations.EntityStrings.Conversions;\n",
    "using YiJingFramework.EntityRelations.EntityStrings.Extensions;\n",
    "using YiJingFramework.EntityRelations.WuxingRelations;\n",
    "using YiJingFramework.EntityRelations.WuxingRelations.Extensions;\n",
    "using YiJingFramework.PrimitiveTypes;"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`YiJingFramework.EntityRelations.WuxingRelations` 命名空间主要五行生克关系，举例而言："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "For Mu, Jin is the Wuxing that KesMe.\n",
      "For Mu, the Wuxing that KesMe is Jin.\n"
     ]
    }
   ],
   "source": [
    "var mu = Wuxing.Mu;\n",
    "var jin = Wuxing.Jin;\n",
    "var s = $\"For {mu}, {jin} is the Wuxing that {mu.GetRelation(jin)}.\";\n",
    "Console.WriteLine(s);\n",
    "\n",
    "var kesMe = WuxingRelation.KesMe;\n",
    "s = $\"For {mu}, the Wuxing that {kesMe} is {mu.GetWuxing(kesMe)}.\";\n",
    "Console.WriteLine(s);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "由于 `WuxingRelation` 是一个枚举类型，它没法重写 `ToString` 。而专门添加转换中文的扩展方法又感觉有些过于特殊化。关于这个问题，可以使用此包中的 [`EntityStrings`](./EntityStrings) 来尝试解决，如："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "金为木之官鬼\r\n"
     ]
    }
   ],
   "source": [
    "var toLiuqin = WuxingRelationToStringConversions.Liuqin;\n",
    "var mu = Wuxing.Mu;\n",
    "var jin = Wuxing.Jin;\n",
    "var s = $\"{jin:C}为{mu:C}之{mu.GetRelation(jin).ToString(toLiuqin)}\";\n",
    "Console.WriteLine(s);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "另外，虽然五行生克关系一般没有其他取法，但还是把结果列在此处：\n",
    "\n",
    "||木|火|土|金|水|\n",
    "|:-:|:-:|:-:|:-:|:-:|:-:|\n",
    "|同我|木|火|土|金|水|\n",
    "|生我|水|木|火|土|金|\n",
    "|我生|火|土|金|水|木|\n",
    "|克我|金|水|木|火|土|\n",
    "|我克|土|金|水|木|火|"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "file_extension": ".cs",
   "mimetype": "text/x-csharp",
   "name": "C#",
   "pygments_lexer": "csharp",
   "version": "3.12.2"
  },
  "polyglot_notebook": {
   "kernelInfo": {
    "defaultKernelName": "csharp",
    "items": [
     {
      "aliases": [],
      "name": "csharp"
     }
    ]
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
